/*
 * Sample.java
 *
 * Copyright 2011 Anish
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aosp.nanoxstream.utils;

import java.util.Vector;

import com.aosp.nanoxstream.Field;
import com.aosp.nanoxstream.XMLStreamProvider;

/**
 * 
 * <code>Sample.java</code>
 * <p> </p>
 * @author Anish , anishkumar.ka@gmail.com
 * <dt><b>Date: </b><dd>Jan 6, 2011
 * <dt><b>Module: </b><dd>nanoxstream-testclient
 * <dt><b>Package: </b><dd>com.aosp.nanoxstream.utils
 * <dt>TODO:<dd>
 */
public class Sample implements XMLStreamProvider{

	private String testName = null;

	private String testAddr = null;
	
	private Vector childSample = new Vector();

	public String getAddressName() {
		return testAddr;
	}

	public Vector getChildSample() {
		return childSample;
	}

	public String getTestName() {
		return testName;
	}


	/*
	 * (non-Javadoc)
	 * @see com.aosp.xmlparser.XMLStreamProvider#getFieldValue(java.lang.String)
	 */
	public Object getFieldValue(String fieldName) {
		if(fieldName.equalsIgnoreCase("testName"))
			return testName;
		if(fieldName.equalsIgnoreCase("testAddr"))
			return testAddr;
		if(fieldName.equalsIgnoreCase("childSample"))
			return childSample;
		return null;
	}


	/*
	 * (non-Javadoc)
	 * @see com.aosp.xmlparser.XMLStreamProvider#setFieldValue(java.lang.String, java.lang.Object)
	 */
	public void setFieldValue(String fieldName, Object newValue) {
		if(fieldName.equalsIgnoreCase("testName")){
			testName = (String) newValue;
		}
		if(fieldName.equalsIgnoreCase("testAddr")){
			testAddr = (String) newValue;
		}
		if(fieldName.equalsIgnoreCase("childSample")){
			childSample.addElement(newValue);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.aosp.xmlparser.XMLStreamProvider#getDeclaredFields()
	 */
	public Vector getDeclaredFields() {
		Vector declaredFields = new Vector();
		declaredFields.addElement(new Field("testName"));
		declaredFields.addElement(new Field("testAddr"));
		declaredFields.addElement(new Field("childSample"));
		return declaredFields;
	}
}

